package com.landscope.issue.exception;

/**
 * 异常枚举
 * @author qzp
 * @version v1.0
 * @date 2021/6/28 14:11
 **/
public enum  E_EXCEPTION_TYPE {
    user_token_invalid(1001, "授权失效，请重新登录"),
    user_nonexistent(1101, "账号不存在"),
    user_wrong_password(1102, "密码错误"),
    user_disable(1103, "账号被禁用"),

    param_validated_exception(1201, "参数异常"),
    param_validated_format_exception(1202, "参数格式异常"),

    data_lock_timeout(1501, "数据锁定超时异常"),
    access_token_invalid(1601, "accessToken无效"),
    has_not_authority(1602, "没有权限"),
    has_not_module_authority(1603, "没有功能权限"),
    ;
    private Integer value;
    private String name;

    E_EXCEPTION_TYPE(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public Integer getValue() {
        return value;
    }
    public String getName() {
        return name;
    }

    public static E_EXCEPTION_TYPE newValueOf(Integer value) {
        if (value == null) {
            return null;
        }
        for (E_EXCEPTION_TYPE status : E_EXCEPTION_TYPE.values()) {
            if (status.getValue().equals(value)) {
                return status;
            }
        }
        throw new IllegalArgumentException("No enum new value " + value);
    }
}
